This is a replication archive for Horiuchi, Smith and Yamamoto, "Measuring Voters' Multidimensional Policy Preferences with Conjoint Analysis: Application to Japan's 2014 Election" in Political Analysis. The archive contains all the material needed to reproduce the results reported in the article.

=====================
Software Dependency
=====================

All scripts have been confirmed to work on macOS Sierra (10.12.6) with the working installation of R 3.3.2 and JAGS 4.2.0 as well as the add-on R packages referred to in the scripts. Note that some of the parallel computing procedures do not work as intended on Windows systems; this is a known limitation of functions such as mclapply() that depend on forking. The code should still run on a single core with appropriate modification to the relevant options, though with substantially more run time.

Several of our results may not exactly replicate depending on the computing environment used, although the general substantive conclusions reported in the article should be unaffected. Specifically, Figure 3 may show noticeably different estimates because of the discrepancy in the ways randomness seeds are implemented across platforms in parallelized computation. In Figure D.3 (and potentially in other figures), some of the plots may be labeled with incorrect attribute labels because of character encoding discrepancies across platforms for the non-ascii variable labels in the original dataset. We have verified that these issues do not arise when the analyses are replicated in another macOS environment different from the one used for the results reported in the article.

==================
Files Contained
==================

2014_Lower_House_Election_in_Japan.csv 
	The main data for the analyses in the paper. This is the original data file downloaded from Qualtrics, with several variables redacted for possible privacy concerns, as explained in the codebook.

codebook.pdf
	The codebook for the main data file.

margin-pop-all
	This directory contains population margins data, as well as the original source data files and documentation for the margins data. Details are provided in the codebook included.

margin-pop-voters
	This directory contains margins data for the voters who actually turned out, as well as the original source data files and documentation for that data. Details are provided in the codebook inside.

HSY-makedata.R                         
	R script that transforms the original data into the analysis dataset. It reads in the main survey data (2014_Lower_House_Election_in_Japan.csv), calculates poststratification weights using the population margins data (in margin-pop-all and margin-pop-voters), and creates two CSV files (election2014-data-long.csv and election2014-data-wide.csv). 

HSY-preprocess.R
	R script that conducts additional pre-processing to the analysis datasets that are common to all estimation procedures. The three main analysis scripts below all call this script at the beginning.

HSY-AMCEs.R 
	The main analysis R script that produces all results in the paper and the supplementary materials, except those separately conducted in the two other scripts below. Depends on amce-custom.R and plot-custom.R.

HSY-heterogen.R
	R script for the effect heterogeneity analysis reported in Figures 2, D.1, D.2 and D.3. Depends on election2014-HLM.jag and requires a working JAGS installation, as well as several helper R packages. Conducts parallel processing across 4 cores by default.

election2014-HLM.jag
	JAGS model declaration used by HSY-heterogen.R. 

HSY-ranking.R
	R script for the ranking analysis reported in Figure 3 and Section 4.3. Conducts parallel processing across 10 cores by default.

plot-custom.R
amce-custom.R
	Contain R functions that are modified versions of the functions of the same names contained in the cjoint package. Used in some of the analyses in HSY-AMCEs.R.

README
	This file.

========================================
How to reproduce results in the article
========================================

0. Set the working directory to the root of this replication archive. Keep the directory structure as is.

1. Run HSY-makedata.R to produce the two analysis data files (election2014-data-long.csv and election2014-data-wide.csv).

2. Run HSY-AMCEs.R to produce all results except Figures 2, 3, D.1, D.2, D.3 and the estimates reported in Section 4.3, which are generated by the separate scripts discussed below.

3. Run HSY-heterogen.R to produce Figures 2, D.1, D.2 and D.3. Computation time is several hours when the computations is parallelized across 4 cores as specified in the code.

4. Run HSY-ranking.R to produce Figure 3 and results in Section 4.3. Computation time is several hours when all 10 cores are used in parallel processing as specified. 

========================================
Contact info
========================================

Please contact the Corresponding Author of the article (Yamamoto, teppei@mit.edu) for any questions about this replication archive.

-------------------
Yusaku Horiuchi, Daniel M. Smith, and Teppei Yamamoto
December 1, 2017




